package com.chao.order.controller;

import com.chao.order.entity.OrderInfo;
import com.chao.order.service.OrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : Rookie
 * @description :
 * @date : 2022/9/18
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Value("${seata.application-id}")
    private String appId;

    @Value("${seata.registry.nacos.namespace}")
    private String namespace;

    @Autowired
    private OrderInfoService orderInfoService;

    @GetMapping("/create")
    public OrderInfo createOrder(@RequestParam String productId) {
        //生成订单
        return orderInfoService.createOrder(productId);
    }

    @GetMapping("/test")
    public Map<String,Object> mapValue() {
        Map<String, Object> hashMap = new HashMap<>();
        hashMap.put("appId",appId);
        hashMap.put("namespace",namespace);
        return hashMap;
    }
}
